diff --git a/tests/test_reconcile.py b/tests/test_reconcile.py index 893dff3c0b1851c48e7a81eb8f3633ea7c64c47b..aa368a882426e20bddfeb7784b13faf8650edfd9 100644 --- a/tests/test_reconcile.py +++ b/tests/test_reconcile.py @@ -5,15 +5,17 @@ import tempfile import textwrap from conservancy_beancount.reconcile.statement_reconciler import ( - match_statement_and_books, - remove_payee_junk, date_proximity, - remove_duplicate_words, - payee_match, + match_statement_and_books, metadata_for_match, - write_metadata_to_books, - totals, + payee_match, + remove_duplicate_words, + remove_payee_junk, + standardize_amex_record, + standardize_fr_record, subset_match, + totals, + write_metadata_to_books, ) # These data structures represent individual transactions as taken from the @@ -341,3 +343,42 @@ def test_subset_passes_through_all_non_matches(): [S1], # No match: preserved intact [B2, B3_next_day, B3_next_week] # No match: preserved intact ) + + +def test_handles_fr_record_with_comma_separators(): + # CSV would look something like: + # + # "Date","ABA Num","Currency","Account Num","Account Name","Description","BAI Code","Amount","Serial Num","Ref Num","Detail" + # "02/07/2022",,,,,,,"10,000.00",,,"XXXX" + input_row = { + 'Date': '02/07/2022', + 'Amount': '10,000.00', + 'Detail': 'XXXX', + 'Serial Num': '', + } + expected = { + 'date': datetime.date(2022, 2, 7), + 'amount': decimal.Decimal('10000'), + 'payee': 'XXXX', + 'check_id': '', + 'line': 1, + } + assert standardize_fr_record(input_row, line=1) == expected + + +def test_handles_amex_record_with_comma_separators(): + # This insn't typically a problem with AMEX, but adding for completeness. + input_row = { + 'Date': '02/07/2022', + 'Amount': '-10,000.00', # Amounts are from Bank's perspective/negated. + 'Description': 'XXXX', + 'Serial Num': '', + } + expected = { + 'date': datetime.date(2022, 2, 7), + 'amount': decimal.Decimal('10000'), + 'payee': 'XXXX', + 'check_id': '', + 'line': 1, + } + assert standardize_amex_record(input_row, line=1) == expected