reconcile: Explicitly avoid payee matching when check-id provided in books.
This commit is contained in:
parent
c9dd9ffb28
commit
517d4027b4
2 changed files with 21 additions and 2 deletions
|
@ -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']:
|
if r1['check_id'] and r2['check_id'] and r1['check_id'] == r2['check_id']:
|
||||||
check_score = 1.0
|
check_score = 1.0
|
||||||
else:
|
else:
|
||||||
check_message = 'Check id not matched'
|
check_message = 'check-id mismatch'
|
||||||
check_score = 0.0
|
check_score = 0.0
|
||||||
else:
|
else:
|
||||||
check_score = 0.0
|
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_score = score
|
||||||
best_match_index = i
|
best_match_index = i
|
||||||
best_match_note = note
|
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:
|
if best_match_score <= 0.8:
|
||||||
best_match_note.append('only one decent match')
|
best_match_note.append('only one decent match')
|
||||||
matches.append(([r1], [books_trans[best_match_index]], best_match_note))
|
matches.append(([r1], [books_trans[best_match_index]], best_match_note))
|
||||||
|
|
|
@ -100,6 +100,15 @@ B3_payee_mismatch_2 = {
|
||||||
'line': 999,
|
'line': 999,
|
||||||
'bank_statement': "Financial/Bank-Statements/AMEX/2022-01-12_AMEX_statement.pdf"
|
'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():
|
def test_one_exact_match():
|
||||||
|
@ -230,3 +239,13 @@ def test_totals():
|
||||||
([S2], [], []),
|
([S2], [], []),
|
||||||
([], [B3_next_day], []),
|
([], [B3_next_day], []),
|
||||||
]) == (decimal.Decimal('10'), decimal.Decimal('20'), decimal.Decimal('30'))
|
]) == (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']),
|
||||||
|
]
|
||||||
|
|
Loading…
Reference in a new issue