Skip to content

feat(hdfc): add HDFC Bank credit card statements - #366

Merged
benjamin-awd merged 2 commits into
benjamin-awd:mainfrom
anandghegde:feat/hdfc-credit
Nov 11, 2026
Merged

benjamin-awd merged 2 commits into
benjamin-awd:mainfrom
anandghegde:feat/hdfc-credit

Conversation

@anandghegde

Copy link
Copy Markdown
Contributor

Adds a parser for HDFC Bank (India) credit card statements. Refs #223.

What it covers

  • The layout HDFC has used since about Aug 2025 (creator Quadient~Inspire)
  • Domestic and international sections
  • Debit/credit direction, INR currency, statement date, billing period start, card last-4

Before this change the generic parser fails on these statements with
GenericParserError: Could not find any transactions.

Things that differ from existing banks

  • Lakh grouping. Amounts print as 1,23,456.78; the shared comma pattern
    reads that as 23,456.78, so the config has its own amount pattern.
  • Reward points next to the credit marker. + 30 ₹978.00 is a debit that
    earned 30 points; + ₹114.50 is a credit. They are matched separately.
  • Descriptions that wrap around their row. Fee and tax rows print the
    description on the lines above and below the date/amount line.
    multiline_descriptions can't express this (the line above would also attach
    to the previous row), so there is a new opt-in
    MultilineConfig.straddled_descriptions and a small
    merge_straddled_descriptions helper next to merge_wrapped_amounts. No
    other bank enables it.

Testing

  • Unit tests for each of the cases above
  • Fixture under tests/integration/banks/hdfc/credit/, built with
    monopoly-fixture from a redacted statement (30 transactions; safety check passes)
  • ruff, mypy src, full test suite pass

Not covered

Add-on cards, EMI conversion rows, older layouts, and HDFC savings/current
accounts. I only have one card type (Diners) to test with; I'd expect other
HDFC cards to share the layout but haven't confirmed it.

The .gitignore commit is unrelated housekeeping (.env wasn't ignored); happy
to split it out.

anandghegde and others added 2 commits November 10, 2026 11:26
The README tells users to put PDF_PASSWORDS in .env, but the file was not
ignored, so a broad git add could stage statement passwords.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Parses the HDFC Bank (India) credit card layout in use since about Aug
2025, covering domestic and international sections, debit/credit
direction, INR currency, statement date, billing period start and card
last-4. Refs benjamin-awd#223.

Three things differ from existing banks:

- Amounts use lakh grouping (1,23,456.78), which the shared comma
  pattern reads as 23,456.78, so the config carries its own amount
  pattern.
- Reward points ("+ 30") sit next to the credit marker ("+" directly
  before the rupee glyph), so the two are matched separately.
- Fee and tax rows print their description on the lines above and below
  the date/amount line. multiline_descriptions cannot express this: the
  line above would also attach to the previous row. A new opt-in
  MultilineConfig.straddled_descriptions merges those neighbours into
  the row before matching, in the same spirit as multiline_amount.

The fixture is a redacted dump of a real statement. Add-on cards, EMI
conversion rows and older layouts are not covered.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@benjamin-awd

Copy link
Copy Markdown
Owner

Thanks @anandghegde!

@benjamin-awd
benjamin-awd merged commit 2f9cf08 into benjamin-awd:main Nov 11, 2026
0 of 7 checks passed
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