diff --git a/src/ofxstatement_fidelity/plugin.py b/src/ofxstatement_fidelity/plugin.py index 7d80bf7..cde05b8 100644 --- a/src/ofxstatement_fidelity/plugin.py +++ b/src/ofxstatement_fidelity/plugin.py @@ -40,6 +40,8 @@ class FidelityCSVParser(AbstractStatementParser): (re.compile(r"^PARTIC CONTR "), "INVBANKTRAN", "CREDIT"), (re.compile(r"^PARTIAL DISTRIBUTION "), "INVBANKTRAN", "DEBIT"), (re.compile(r"^FED TAX W/H "), "INVBANKTRAN", "DEBIT"), + (re.compile(r"^DISTRIBUTION "), "TRANSFER", "IN"), + (re.compile(r"^IN LIEU OF FRX SHARE SPINOFF "), "INCOME", "MISC"), ] def __init__(self, filename: str) -> None: @@ -132,9 +134,14 @@ def parse_record(self, line): invest_stmt_line.unit_price = self.parse_decimal(line[5]) invest_stmt_line.units = self.parse_decimal(line[6]) + elif invest_stmt_line.trntype == "TRANSFER": + invest_stmt_line.security_id = line[2] + invest_stmt_line.units = self.parse_decimal(line[6]) + invest_stmt_line.unit_price = invest_stmt_line.amount / invest_stmt_line.units + elif ( invest_stmt_line.trntype == "INCOME" - and invest_stmt_line.trntype_detailed == "DIV" + and invest_stmt_line.trntype_detailed in ("DIV", "MISC") ): invest_stmt_line.security_id = line[2] diff --git a/tests/History_for_Account_TEST2139.csv b/tests/History_for_Account_TEST2139.csv index 2b4cc61..56eb5f5 100644 --- a/tests/History_for_Account_TEST2139.csv +++ b/tests/History_for_Account_TEST2139.csv @@ -1,6 +1,9 @@ Run Date,Action,Symbol,Description,Type,Price ($),Quantity,Commission ($),Fees ($),Accrued Interest ($),Amount ($),Cash Balance ($),Settlement Date +01/29/2025,"IN LIEU OF FRX SHARE SPINOFF FROM:(CONS) ACME CORP (ACME) (Cash)",ACME,"ACME CORP",Cash,,0.000,,,,3.78,74003.45, +01/29/2025,"DISTRIBUTION SPINOFF FROM:(CONS) ACME CORP (ACME) (Cash)",ACME,"ACME CORP",Shares,,3,,,,61.98,73999.67, +01/28/2025,"DISTRIBUTION ACME CORP (ACME) (Cash)",ACME,"OBFUSCATED DESCRIPTION",Shares,,3.000,,,,101.00,73999.67, 01/28/2026,YOU BOUGHT PROSPECTUS UNDER SEPARATE COVER FIDELITY 500 INDEX FUND (FXAIX) (Cash),FXAIX,OBFUSCATED DESCRIPTION,Cash,55.274,169.59,,,,-9373.92,73696.67,01/29/2026 01/26/2026,YOU BOUGHT PROSPECTUS UNDER SEPARATE COVER FIDELITY 500 INDEX FUND (FXAIX) (Cash),FXAIX,OBFUSCATED DESCRIPTION,Cash,58.558,172.72,,,,-10114.14,63582.53,01/27/2026 01/26/2026,CONTRIBUTION VS XXX-XXXXXX-X EMPLOYER CONTR (Cash),,OBFUSCATED DESCRIPTION,Cash,,0.00,,,,551.24,64133.77,