Skip to content

Commit 63e2a6f

Browse files
authored
Merge pull request #33 from codereverser/feature/capital-gains-report
generate Capital Gains Report
2 parents 5eb2478 + b5b8508 commit 63e2a6f

File tree

19 files changed

+662
-93
lines changed

19 files changed

+662
-93
lines changed

CHANGELOG.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
# Changelog
22

3+
## 0.5.0 - 2021-07-02
4+
- Support for calculating capital gains from detailed CAS statements
5+
6+
37
## 0.4.8 - 2021-06-27
48
- `REVERSAL` TransactionType to indicate reverted/rejected transactions
59
- convert all enums to strEnums for better readability [(#35)](https://github.com/codereverser/casparser/pull/35)
610
- fix issue with parsing multi-line transactions
711

812
## 0.4.7 - 2021-06-01
913

10-
- Minor bug fixes in summary statement parser.
14+
- Minor bug fixes in summary-statement parser.
1115
- cli now uses [rich](http://rich.readthedocs.io/) for console output.
12-
- Dependency management and deployment is handled by poetry.
16+
- Use poetry for dependency management and deployment.
1317
- **BREAKING CHANGE**: Table output choices have been removed.
1418
`-s/--summary` is a flag and doesn't accept any additional arguments.
1519
- Support for folios without PAN (#28).
1620
- add support for new style dividend transactions after IDCW renaming.
17-
- improved transaction entry parser.
21+
- improved parser for transaction entries.
1822

1923
## 0.4.6 - 2021-04-04
2024

@@ -97,8 +101,8 @@
97101

98102
## 0.3.0 - 2020-10-25
99103

100-
- **Breaking Change**: `folios` is a list instead of dict, so that the order is
101-
preserved during format conversion to other data types like json.
104+
- **Breaking Change**: In order to preserve the order of entries, during format
105+
conversion to other data types like json., `folios` is a list instead of dict.
102106
- Added a second parser based on [PyMuPDF](https://github.com/pymupdf/PyMuPDF) /
103107
[MuPDF](https://mupdf.com/) - ~15-20x faster compared to pure-python pdfminer.
104108
- Added AMC detection (accessible via `amc` property of folio)

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
Parse Consolidated Account Statement (CAS) PDF files generated from CAMS/KFINTECH
1010

11+
`casparser` also includes a command line tool with the following analysis tools
12+
- `summary`- print portfolio summary
13+
- `gains`- Print capital gains report (summary and detailed)
14+
1115

1216
## Installation
1317
```bash
@@ -118,7 +122,7 @@ Notes:
118122
casparser also comes with a command-line interface that prints summary of parsed
119123
portfolio in a wide variety of formats.
120124

121-
```bash
125+
```
122126
Usage: casparser [-o output_file.json|output_file.csv] [-p password] [-s] [-a] CAS_PDF_FILE
123127
124128
-o, --output FILE Output file path. Saves the parsed data as json or csv
@@ -129,21 +133,45 @@ Usage: casparser [-o output_file.json|output_file.csv] [-p password] [-s] [-a] C
129133
-p PASSWORD CAS password
130134
-a, --include-all Include schemes with zero valuation in the
131135
summary output
132-
--sort Sort transactions by date
136+
-g, --gains Generate Capital Gains Report (BETA) [Debt fund indexation not
137+
considered]
133138
--force-pdfminer Force PDFMiner parser even if MuPDF is
134139
detected
135140
136141
--version Show the version and exit.
137142
-h, --help Show this message and exit.
138143
```
139144

145+
#### CLI examples
146+
```
147+
# Print portfolio summary
148+
casparser /path/to/cas.pdf -p password
149+
150+
# Print portfolio and capital gains summary
151+
casparser /path/to/cas.pdf -p password -g
152+
153+
# Save parsed data as a json file
154+
casparser /path/to/cas.pdf -p password -o pdf_parsed.json
155+
156+
# Save parsed data as a csv file
157+
casparser /path/to/cas.pdf -p password -o pdf_parsed.csv
158+
159+
# Save capital gains transactions in csv files (pdf_parsed-gains-summary.csv and
160+
# pdf_parsed-gains-detailed.csv)
161+
casparser /path/to/cas.pdf -p password -g -o pdf_parsed.csv
162+
163+
```
164+
140165
**Note:** `casparser cli` supports two special output file formats [-o _file.json_ / _file.csv_]
141166
1. `json` - complete parsed data is exported in json format (including investor info)
142167
2. `csv` - Summary info is exported in csv format if the input file is a summary statement or if
143168
a summary flag (`-s/--summary`) is passed as argument to the CLI. Otherwise, full
144169
transaction history is included in the export.
170+
If `-g` flag is present, two additional files '{basename}-gains-summary.csv',
171+
'{basename}-gains-detailed.csv' are created with the capital-gains data.
145172
3. any other extension - The summary table is saved in the file.
146173

174+
147175
#### Demo
148176

149177
![demo](https://raw.githubusercontent.com/codereverser/casparser/main/assets/demo.jpg)

casparser/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from .parsers import read_cas_pdf
2+
from .analysis import CapitalGainsReport
23
from .types import CASParserDataType
34
from .__version__ import __version__
45

56
__all__ = [
67
"read_cas_pdf",
78
"__version__",
89
"CASParserDataType",
10+
"CapitalGainsReport",
911
]

casparser/analysis/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .gains import CapitalGainsReport
2+
3+
__all__ = ["CapitalGainsReport"]

0 commit comments

Comments
 (0)