Skip to content

Commit 9f7fe4d

Browse files
committed
add TransactionType.REVERSAL to denote rejected transactions
1 parent a66ad98 commit 9f7fe4d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

casparser/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ class TransactionType(Enum):
3232
SEGREGATION = auto()
3333
MISC = auto()
3434
UNKNOWN = auto()
35+
REVERSAL = auto()

casparser/process/cas_detailed.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ def get_transaction_type(
5656
else:
5757
txn_type = TransactionType.PURCHASE
5858
elif units < 0:
59-
if "switch" in description:
59+
if re.search("reversal|rejection|dishonoured", description, re.I):
60+
txn_type = TransactionType.REVERSAL
61+
elif "switch" in description:
6062
if "merger" in description:
6163
txn_type = TransactionType.SWITCH_OUT_MERGER
6264
else:

tests/test_process.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def test_transaction_type(self):
5555
None,
5656
)
5757

58+
assert get_transaction_type(
59+
"Purchase SIPCheque Dishonoured - Instalment No 108", Decimal(-1.0)
60+
) == (TransactionType.REVERSAL, None)
61+
5862
def test_isin_search(self):
5963
isin, amfi = isin_search(
6064
"Axis Long Term Equity Fund - Direct Growth", "KFINTECH", "128TSDGG"

0 commit comments

Comments
 (0)