Skip to content

fix: support Indonesian currency format and fix NoneType error in pdfoxide parser - #23

Open
rager306 wants to merge 1 commit into
mainfrom
fix-indonesian-amounts-pdfoxide-1786048993213094149
Open

fix: support Indonesian currency format and fix NoneType error in pdfoxide parser#23
rager306 wants to merge 1 commit into
mainfrom
fix-indonesian-amounts-pdfoxide-1786048993213094149

Conversation

@rager306

@rager306 rager306 commented Jan 29, 2026

Copy link
Copy Markdown
Owner

This PR addresses two issues:

  1. The regex pattern for amounts _AMOUNT_PATTERN only supported US format (dot decimal), causing Indonesian amounts (comma decimal) to be misidentified or ignored. It has been updated to support both.
  2. The pdfoxide parser could raise a TypeError if extract_text returned None, as the fallback or "" was effectively commented out by a type: ignore comment. This has been fixed to ensure safe string concatenation.

Tests have been added to verify the fix for Indonesian amounts, and existing tests pass.


PR created automatically by Jules for task 1786048993213094149 started by @rager306

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced PDF text extraction to handle edge cases more reliably.
  • New Features

    • Added support for multiple number formats (US: 1,234.56 and Indonesian: 1.234,56) in monetary value parsing.
  • Tests

    • Added test coverage for locale-aware number format parsing across different regional formats.

✏️ Tip: You can customize this high-level summary in your review settings.

…oxide parser

- Update `_AMOUNT_PATTERN` in `pdfparser/utils.py` to support Indonesian currency format (comma decimal).
- Fix potential `TypeError` in `pdfparser/pdfoxide_parser.py` when `extract_text` returns `None`.
- Add tests for Indonesian and US currency formats in `tests/test_utils.py`.

Co-authored-by: rager306 <248269686+rager306@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Jan 29, 2026

Copy link
Copy Markdown

Walkthrough

This PR fixes a potential None handling issue in PDF text extraction and extends monetary value parsing to support both US and Indonesian number formats. Two test cases validate the locale-aware number parsing functionality.

Changes

Cohort / File(s) Summary
PDF Text Extraction Fix
pdfparser/pdfoxide_parser.py
Fixed None handling in PDF text extraction by coercing None results to empty strings using or "", ensuring each page appends a string value even when extraction yields None.
Locale-Aware Number Format Support
pdfparser/utils.py
Updated _AMOUNT_PATTERN regex to accept both US (1,234.56) and Indonesian (1.234,56) decimal formats by expanding pattern to `r"^(?:[\d,]+.\d{2}
Test Coverage
tests/test_utils.py
Added two new unit tests (test_extract_transactions_indonesian_format, test_extract_transactions_us_format) validating extraction of transactions with locale-specific number formatting and field parsing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes both main changes in the PR: fixing a NoneType error in the pdfoxide parser and adding support for Indonesian currency format.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-indonesian-amounts-pdfoxide-1786048993213094149

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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