Skip to content

Commit

Permalink
Support Same-Day ACH transactions in checking (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlynch authored Jun 27, 2024
1 parent e33c1d9 commit 720d16b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ ignored-argument-names=_.*
max-locals=30

# Maximum number of return / yield for function / method body
max-returns=6
max-returns=100

# Maximum number of branch for function / method body
max-branches=12
Expand Down
6 changes: 6 additions & 0 deletions beancount_chase/checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ 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)

_INBOUND_TRANSFER_PATTERN = re.compile(
r'Online Transfer \d+ from (.+?)\s*transaction #', re.IGNORECASE)

Expand All @@ -143,6 +146,9 @@ def _parse_description(description):
if match:
return match.group(1), match.group(2)
match = _OUTBOUND_TRANSFER_PATTERN.search(description)
if match:
return match.group(1), description
match = _SAME_DAY_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 @@ -48,6 +48,24 @@ def test_extracts_outbound_transfer(tmp_path):
""".rstrip()) == _stringify_directives(directives).strip()


def test_extracts_same_day_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,05/24/2024,"Same-Day ACH Payment 12232800456 to JoeExample (_######9587)",-87.50,ACH_PAYMENT,6788.52,,
"""))

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

assert _unindent("""
2024-05-24 * "JoeExample" "Same-Day ACH Payment 12232800456 to JoeExample (_######9587)"
Assets:Checking:Chase -87.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 720d16b

Please sign in to comment.