From 8a77aff7eb7418d9450f542801e4735c733f8f51 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Wed, 6 Sep 2023 10:20:04 -0400 Subject: [PATCH] Gracefully handle monthly service fee lines (#91) --- beancount_chase/checking.py | 2 ++ beancount_chase/checking_test.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/beancount_chase/checking.py b/beancount_chase/checking.py index d862eea..b45dc44 100644 --- a/beancount_chase/checking.py +++ b/beancount_chase/checking.py @@ -137,4 +137,6 @@ def _parse_description(description): match = _INBOUND_TRANSFER_PATTERN.search(description) if match: return match.group(1), description + if description == 'MONTHLY SERVICE FEE': + return description, description return None, None diff --git a/beancount_chase/checking_test.py b/beancount_chase/checking_test.py index 0e01bef..0e3813f 100644 --- a/beancount_chase/checking_test.py +++ b/beancount_chase/checking_test.py @@ -48,6 +48,24 @@ def test_extracts_outbound_transfer(tmp_path): """.rstrip()) == _stringify_directives(directives).strip() +def test_extracts_monthly_account_fee(tmp_path): + chase_file = tmp_path / 'Chase1234_Activity_20230919.CSV' + chase_file.write_text( + _unindent(""" + Details,Posting Date,Description,Amount,Type,Balance,Check or Slip # + DEBIT,08/31/2023,"MONTHLY SERVICE FEE",-15.00,FEE_TRANSACTION,2118.39,, + """)) + + with chase_file.open() as f: + directives = CheckingImporter(account='Assets:Checking:Chase', + lastfour='1234').extract(f) + + assert _unindent(""" + 2023-08-31 * "Monthly Service Fee" "Monthly Service Fee" + Assets:Checking:Chase -15.00 USD + """.rstrip()) == _stringify_directives(directives).strip() + + def test_extracts_credit(tmp_path): chase_file = tmp_path / 'Chase1234_Activity_20211019.CSV' chase_file.write_text(