Changeset - 5793a55dbcc6
[Not reviewed]
0 2 0
Ben Sturmfels (bsturmfels) - 19 months ago 2023-02-11 07:54:52
ben@sturm.com.au
reconciler: Fix reconciler lumping unmatched books items together (#20737)

Issue was that the subset matching was passing through the grouped transactions
rather than the original transactions when it failed to match.
2 files changed with 28 insertions and 1 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reconcile/statement_reconciler.py
Show inline comments
...
 
@@ -503,7 +503,7 @@ def subset_match(
 
            if best_match_index is not None:
 
                del statement_trans[best_match_index]
 
        else:
 
            remaining_books_trans.append(r2)
 
            remaining_books_trans.extend(group_items)
 
    for r1 in statement_trans:
 
        remaining_statement_trans.append(r1)
 
    return matches, remaining_statement_trans, remaining_books_trans
tests/test_reconcile.py
Show inline comments
...
 
@@ -350,6 +350,33 @@ def test_subset_passes_through_all_non_matches():
 
    )
 

	
 

	
 
def test_subset_passes_though_unmatched_transactions_with_same_payee():
 
    # Tracy noticed that when multiple books payments had the same date and
 
    # payee and were unmatched, they were being displayed lumped together, when
 
    # they should have remained separate.
 
    B1a = {
 
        'date': datetime.date(2022, 1, 1),
 
        'amount': decimal.Decimal('100.00'),
 
        'payee': 'Hannah',
 
        'check_id': '',
 
        'filename': '2022/imports.beancount',
 
        'line': 777,
 
        'bank_statement': '',
 
    }
 
    B1b = {
 
        'date': datetime.date(2022, 1, 1),
 
        'amount': decimal.Decimal('100.00'),
 
        'payee': 'Hannah',
 
        'check_id': '',
 
        'filename': '2022/imports.beancount',
 
        'line': 797,
 
        'bank_statement': '',
 
    }
 
    assert subset_match([], [B1a, B1b]) == (
 
        [], [], [B1a, B1b],  # No match: two preserved intact
 
    )
 

	
 

	
 
def test_handles_amex_csv():
 
    CSV = """Date,Receipt,Description,Card Member,Account #,Amount,Extended Details,Appears On Your Statement As,Address,City/State,Zip Code,Country,Reference,Category\n08/19/2021,,Gandi.net           San Francisco,RODNEY R BROWN,-99999,28.15,"00000009999 00000009999999999999\nGandi.net\nSan Francisco\n00000009999999999999",Gandi.net           San Francisco,"NEPTUNUSSTRAAT 41-63\nHOOFDDORP",,2132 JA,NETHERLANDS (THE),'999999999999999999',Merchandise & Supplies-Internet Purchase\n"""
 
    expected = [
0 comments (0 inline, 0 general)