Skip to content

feat: add CDSL Consolidated Account Statement support#122

Merged
codereverser merged 1 commit into
codereverser:mainfrom
ratankumarorg-source:feat/cdsl-cas-support
May 10, 2026
Merged

feat: add CDSL Consolidated Account Statement support#122
codereverser merged 1 commit into
codereverser:mainfrom
ratankumarorg-source:feat/cdsl-cas-support

Conversation

@ratankumarorg-source
Copy link
Copy Markdown

Summary

  • Adds full CDSL (Central Depository Services) CAS PDF parsing support
  • Previously casparser only supported NSDL demat CAS statements; CDSL files crashed with "Error parsing CAS header"

Changes

New file: casparser/process/cdsl_statement.py

Complete CDSL CAS parser that extracts:

  • Demat holdings: equities, mutual funds held in demat form, and bonds
  • Mutual fund folio holdings: scheme name, ISIN, closing units, NAV, valuation
  • Handles multi-line security names, page breaks within holding sections, and Indian number formatting

Modified: casparser/process/__init__.py

  • Route FileType.CDSL to the new process_cdsl_text parser

Modified: casparser/process/nsdl_statement.py

  • Fix parse_header to search the full extracted text instead of just text[:1000] (the properly formatted date on some CAS statements falls beyond the first 1000 characters)

Modified: casparser/cli.py

  • Fix formatINR to consistently produce 2 decimal places (previously dropped trailing zeros e.g. ₹1,00,390.0 → now ₹1,00,390.00)
  • Add asset class breakdown summary in print_nsdl showing Debts, Equities (demat), Mutual Funds (demat), Mutual Fund Folios totals
  • Improve table column sizing (max_width/overflow on Name column, fixed ISIN column width) to prevent content truncation

Testing

Successfully parsed a 21-page CDSL CAS PDF containing:

  • 2 demat accounts (28 equities + 11 MFs in demat + 1 bond)
  • 7 mutual fund folios
  • Total portfolio value: ₹1,64,79,242.07

All existing parsers (CAMS, Kfintech, NSDL) remain unchanged.

- Add cdsl_statement.py with full CDSL CAS parser
  - Parse demat holdings (equities, mutual funds in demat, bonds)
  - Parse mutual fund folio holdings
  - Handle multi-line security names and page breaks
- Route FileType.CDSL to the new parser in process/__init__.py
- Fix nsdl_statement.py parse_header to search full text not just [:1000]
- Fix formatINR in cli.py (decimal places, Indian grouping)
- Add asset class breakdown summary in print_nsdl output
- Improve table column sizing to prevent overflow truncation
@codereverser codereverser merged commit e32b5e8 into codereverser:main May 10, 2026
@codereverser
Copy link
Copy Markdown
Owner

Many thanks for the PR. It was a long-standing feature request.

I noticed that it breaks for one CDSL CAS statement I have (works on others), but the issue is with the parser, not the code here. I'll try to fix it in a separate PR.

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