Skip to content

Commit

Permalink
Add support for real-time payment fees (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlynch authored Jul 26, 2024
1 parent bafdbe8 commit a17220d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions beancount_chase/checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ def _extract_transaction_from_row(self, row, metadata):
_MONTHLY_SERVICE_FEE_REVERSAL_PATTERN = re.compile(
r'^Monthly Service Fee Reversal ', re.IGNORECASE)

_REAL_TIME_PAYMENT_FEE_PATTERN = re.compile(r'^RTP/(.+)', re.IGNORECASE)


def _parse_description(description):
match = _DESCRIPTION_PATTERN.search(description)
Expand All @@ -160,4 +162,7 @@ def _parse_description(description):
match = _MONTHLY_SERVICE_FEE_REVERSAL_PATTERN.search(description)
if match:
return description, None
match = _REAL_TIME_PAYMENT_FEE_PATTERN.search(description)
if match:
return 'Real-Time Payments: ' + match.group(1), None
return None, None
18 changes: 18 additions & 0 deletions beancount_chase/checking_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@ def test_extracts_monthly_account_fee_refund(tmp_path):
""".rstrip()) == _stringify_directives(directives).strip()


def test_extracts_real_time_payment_fee(tmp_path):
chase_file = tmp_path / 'Chase1234_Activity_20240309.CSV'
chase_file.write_text(
_unindent("""
Details,Posting Date,Description,Amount,Type,Balance,Check or Slip #
DEBIT,06/03/2024,"RTP/Same Day - Low Value",-1.75,FEE_TRANSACTION,6786.77,,
"""))

with chase_file.open() as f:
directives = CheckingImporter(account='Assets:Checking:Chase',
lastfour='1234').extract(f)

assert _unindent("""
2024-06-03 * "Real-Time Payments: Same Day - Low Value" ""
Assets:Checking:Chase -1.75 USD
""".rstrip()) == _stringify_directives(directives).strip()


def test_doesnt_title_case_if_asked_not_to(tmp_path):
chase_file = tmp_path / 'Chase1234_Activity_20230919.CSV'
chase_file.write_text(
Expand Down

0 comments on commit a17220d

Please sign in to comment.