diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cd7f66..0d5255e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 1.2.1 + +### Fixed + +- Fix mis-classification of STP (Systematic Transfer Plan) for + Kfintech-serviced schemes. (discussion #141) + ## 1.2.0 ### New diff --git a/casparser/__init__.py b/casparser/__init__.py index b106f27..19ccb3b 100644 --- a/casparser/__init__.py +++ b/casparser/__init__.py @@ -9,4 +9,4 @@ __all__ = [ "CapitalGainsReport", ] -__version__ = "1.2.0" +__version__ = "1.2.1" diff --git a/casparser/parsers/_classify.py b/casparser/parsers/_classify.py index f92a055..52baa1f 100644 --- a/casparser/parsers/_classify.py +++ b/casparser/parsers/_classify.py @@ -37,6 +37,15 @@ DIVIDEND_RE = re.compile( ) REINVEST_RE = re.compile(r"reinvest", re.I) +# Systematic Transfer Plan. A switch by another name — money is moved +# between two schemes on a schedule. The two RTAs word it differently: +# CAMS prints "Systematic Transfer Plan Switch In/Out …" (already caught by +# the "switch" keyword), while KFintech prints it letter-spaced as +# "S T P In/Out (…)", which matches none of the plain substring checks and +# used to fall through to PURCHASE / REDEMPTION. Detecting it here — spacing +# tolerated — lets both RTAs classify consistently as SWITCH_IN / SWITCH_OUT. +STP_RE = re.compile(r"\bs\s*t\s*p\b|systematic\s+transfer", re.I) + # Counterparty folio embedded in a gift transfer description. Both RTAs # name the other folio but punctuate differently — KFin uses a colon # ("Folio No: 12345678901"), CAMS a dot ("Folio No.87654321") — so accept @@ -82,7 +91,7 @@ def get_transaction_type( elif units > 0: if "gift" in description: txn_type = TransactionType.GIFT_IN - elif "switch" in description: + elif "switch" in description or STP_RE.search(description): txn_type = ( TransactionType.SWITCH_IN_MERGER if "merger" in description @@ -109,7 +118,7 @@ def get_transaction_type( re.I, ): txn_type = TransactionType.REVERSAL - elif "switch" in description: + elif "switch" in description or STP_RE.search(description): txn_type = ( TransactionType.SWITCH_OUT_MERGER if "merger" in description