diff --git a/conservancy_beancount/reconcile/prototype_amex_reconciler.py b/conservancy_beancount/reconcile/prototype_amex_reconciler.py index 274c692..3d6cc87 100644 --- a/conservancy_beancount/reconcile/prototype_amex_reconciler.py +++ b/conservancy_beancount/reconcile/prototype_amex_reconciler.py @@ -223,7 +223,7 @@ def records_match(r1: Dict, r2: Dict) -> Tuple[bool, str]: if r1['check_id'] and r2['check_id'] and r1['check_id'] == r2['check_id']: check_score = 1.0 else: - check_message = 'Check id not matched' + check_message = 'check-id mismatch' check_score = 0.0 else: check_score = 0.0 @@ -267,7 +267,7 @@ def match_statement_and_books(statement_trans: list, books_trans: list): best_match_score = score best_match_index = i best_match_note = note - if best_match_score > 0.5 and matches_found == 1 and 'payee_mismatch' not in best_match_note or best_match_score > 0.8: + if best_match_score > 0.5 and matches_found == 1 and 'check-id mismatch' not in best_match_note or best_match_score > 0.8: if best_match_score <= 0.8: best_match_note.append('only one decent match') matches.append(([r1], [books_trans[best_match_index]], best_match_note)) diff --git a/tests/test_reconcile.py b/tests/test_reconcile.py index ba3d33b..186b5e5 100644 --- a/tests/test_reconcile.py +++ b/tests/test_reconcile.py @@ -100,6 +100,15 @@ B3_payee_mismatch_2 = { 'line': 999, 'bank_statement': "Financial/Bank-Statements/AMEX/2022-01-12_AMEX_statement.pdf" } +B3_unmatched_check_id = { + 'date': datetime.date(2022, 1, 3), + 'amount': decimal.Decimal('30.00'), + 'payee': 'USPS', + 'check_id': '1234', + 'filename': '2022/main.beancount', + 'line': 999, + 'bank_statement': "Financial/Bank-Statements/AMEX/2022-01-12_AMEX_statement.pdf" +} def test_one_exact_match(): @@ -230,3 +239,13 @@ def test_totals(): ([S2], [], []), ([], [B3_next_day], []), ]) == (decimal.Decimal('10'), decimal.Decimal('20'), decimal.Decimal('30')) + + +def test_payee_not_considered_if_check_id_present(): + # These records match aside from check-id. + statement = [S3] + books = [B3_unmatched_check_id] + assert match_statement_and_books(statement, books) == [ + ([S3], [], ['no match']), + ([], [B3_unmatched_check_id], ['no match']), + ]