Skip to content

Commit

Permalink
Match other types of ACH payment (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlynch authored Dec 4, 2024
1 parent 82d2e86 commit 6b92162
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions beancount_chase/checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def _extract_transaction_from_row(self, row, metadata):
_OUTBOUND_TRANSFER_PATTERN = re.compile(
r'Online Transfer \d+ to (.+?)\s*transaction #', re.IGNORECASE)

_SAME_DAY_ACH_PAYMENT_PATTERN = re.compile(
r'^Same-Day ACH Payment \d+ to ([A-Za-z]+) \(_#+\d+\)$', re.IGNORECASE)
_ACH_PAYMENT_PATTERN = re.compile(
r'^[a-z-]+ ACH Payment \d+ to ([a-z]+) \(_#+\d+\)$', re.IGNORECASE)

_INBOUND_TRANSFER_PATTERN = re.compile(
r'Online Transfer \d+ from (.+?)\s*transaction #', re.IGNORECASE)
Expand All @@ -149,7 +149,7 @@ def _parse_description(description):
match = _OUTBOUND_TRANSFER_PATTERN.search(description)
if match:
return match.group(1), description
match = _SAME_DAY_ACH_PAYMENT_PATTERN.search(description)
match = _ACH_PAYMENT_PATTERN.search(description)
if match:
return match.group(1), description
match = _INBOUND_TRANSFER_PATTERN.search(description)
Expand Down
18 changes: 18 additions & 0 deletions beancount_chase/checking_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ def test_extracts_same_day_ach_transaction(tmp_path):
""".rstrip()) == _stringify_directives(directives).strip()


def test_extracts_standard_ach_transaction(tmp_path):
chase_file = tmp_path / 'Chase1234_Activity_20211019.CSV'
chase_file.write_text(
_unindent("""
Details,Posting Date,Description,Amount,Type,Balance,Check or Slip #
DEBIT,11/06/2024,"Online ACH Payment 12232800456 To JaneExample (_######9587)",-37.50,ACH_PAYMENT,4555.10,,
"""))

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

assert _unindent("""
2024-11-06 * "JaneExample" "Online ACH Payment 12232800456 to JaneExample (_######9587)"
Assets:Checking:Chase -37.50 USD
""".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(
Expand Down

0 comments on commit 6b92162

Please sign in to comment.